package com.yxj01;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListDemo01 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<String>();
        list.add("hello");
        list.add("world");
        list.add("java");

        //void add(int index, E element)
        //list.add(1,"123");
        //E remove(int index)
        //.out.println(list.remove(1));
        //E set(int index, E element)
        //System.out.println(list.set(1,"yxj"));
        //E get(int index)
        //System.out.println(list.get(1));
//        System.out.println(list);
/*        Iterator<String> it = list.iterator();
        while(it.hasNext()) {
            String s = it.next();
            System.out.println(s);
        }*/
        //另一种循环方式
        for(int i = 0; i < list.size(); i++) {
            String s = list.get(i);
            System.out.println(s);
        }
    }
}
